<template>
  <BasicModal :show="show" :showFooter="false" width="55%" title="简历修改记录">
    <template #content>
      <div class="record">
        <div class="record-item" v-for="item in recordList" :key="item.label" v-if="recordList.length > 0">
          <div class="top">
            <div class="label">修改{{ item.type }}</div>
            <div class="time">
              <i class="iconfont icon-shijian"></i>
              <span>{{ item.createTime }}</span>
            </div>
          </div>
          <div class="bottom">
            <div class="change">
              <div class="before ell" :title="item.oldResource">{{ item.oldResource||"无" }}</div>
              <div>修改后</div>
              <div class="after ell" :title="item.newResource">{{ item.newResource }}</div>
            </div>
            <div class="add">
              <p>{{ item.content }}</p>
            </div>
            <div class="opeartor">
              操作人：{{ item.operator }}
            </div>
          </div>
        </div>
        <a-empty v-else />
      </div>
    </template>
  </BasicModal>
</template>

<script setup lang='ts'>
import { ref, watch } from "vue"
import BasicModal from './BasicModal.vue';
import { selectResumesLogList } from "@/api/application-details/index.ts";
import { comStores } from '@/store/common/comStore';
import { message } from "ant-design-vue";
import { title } from "process";
const show = ref<boolean>(false);
const recordList = ref<any>([
]);

const store = comStores()
watch(() => show.value, (val) => {
  if (val) {
    getRecord()
  }
});
const getRecord = async () => {
  const { resumeId } = store.currentResume
  const data = await selectResumesLogList({ resumeId, logType: 0 });
  if (data && data.code == '10000') {
    recordList.value = data.data
  } else {
    message.error(data.msg)
  }
}
defineExpose({ show })
</script>

<style lang="less" scoped>
.record-item {
  width: 100%;
  background: #F5F7FB;
  border-radius: 10px 10px 10px 10px;
  margin-bottom: 20px;
  padding: 17px 20px;
  box-sizing: border-box;
  position: relative;

  .top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .label {
      font-weight: 500;
      font-size: 16px;
      color: #333333;
      line-height: 23px;

    }

    .time {
      display: flex;
      align-items: center;
      gap: 5px;
      color: #abbacd;
    }
  }

  .bottom {
    display: flex;
    align-items: center;
    margin-top: 17px;

    .change {
      display: flex;
      gap: 30px;
      font-size: 14px;
      color: #333;

      .before {
        text-decoration: line-through;
        color: #ABBACD;
      }
    }

    .add {
      p {
        color: #333;
        line-height: 31px;
        font-size: 18px;
        white-space: pre-line
      }
    }
  }

  .opeartor {
    position: absolute;
    right: 20px;
    bottom: 19px;
    color: #666;
  }
}

.ell {
  display: block;
  width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>